<!doctype html>
<html class="bg-main">

<head>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
  <meta name="format-detection" content="telephone=no" />
  <style>
    .s-bg {
      position: fixed;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: url(images/share_bg.jpg) center no-repeat;
      background-size: 100% auto;
    }
    .s-mask{
      display: none;
      position: fixed;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0,0,0,.7);
    }
    .s-step-1{
      position: absolute;
      right: .7rem;
      top: .5rem;
      width: 5.3rem;
      height: 4rem;
      background: url(images/share_1.png) right top no-repeat;
      background-size: auto 100%;
    }
    .s-step-icon{
      position: absolute;
      bottom: 0;
      left: -1.3rem;
      width: 1.3rem;
      height: 1.3rem;
      background: url(images/share_1.png) left bottom no-repeat;
      background-size: auto 150px;
    }
    .s-step-icon-other{
      background-position: 0 -50px;
    }
    .s-step-2{
      position: absolute;
      left: 50%;
      top: 50%;
      width: 5.68rem;
      height: 3.1rem;
      background: url(images/share_2.png) center no-repeat;
      background-size: 100% auto;
      margin-left: -2.4rem;
    }
  </style>
  <script>
    var _hmt = _hmt || [];
    (function () {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?a7ca7eb82a35336b252c83cb5db50989";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
  
</head>

<body>

  <div class="s-bg" onclick="gotoApp()">
  </div>
  <div id="sMask" class="s-mask">
    <div class="s-step-1">
      <span id="sStepIcon" class="s-step-icon s-step-icon-other"></span>
    </div>
    <div class="s-step-2"></div>
  </div>
</body>
  <script>
    // rem布局
    !function(e,t){function i(){var t=n.getBoundingClientRect().width;t/m>540&&(t=540*m);var i=t/10;n.style.fontSize=i+"px",d.rem=e.rem=i}var a,r=e.document,n=r.documentElement,o=r.querySelector('meta[name="viewport"]'),l=r.querySelector('meta[name="flexible"]'),m=0,s=0,d=t.flexible||(t.flexible={});if(o){console.warn("将根据已有的meta标签来设置缩放比例");var p=o.getAttribute("content").match(/initial\-scale=([\d\.]+)/);p&&(s=parseFloat(p[1]),m=parseInt(1/s))}else if(l){var c=l.getAttribute("content");if(c){var u=c.match(/initial\-dpr=([\d\.]+)/),f=c.match(/maximum\-dpr=([\d\.]+)/);u&&(m=parseFloat(u[1]),s=parseFloat((1/m).toFixed(2))),f&&(m=parseFloat(f[1]),s=parseFloat((1/m).toFixed(2)))}}if(!m&&!s){var v=(e.navigator.appVersion.match(/android/gi),e.navigator.appVersion.match(/iphone/gi)),h=e.devicePixelRatio;m=v?h>=3&&(!m||m>=3)?3:h>=2&&(!m||m>=2)?2:1:1,s=1/m}if(n.setAttribute("data-dpr",m),!o)if(o=r.createElement("meta"),o.setAttribute("name","viewport"),o.setAttribute("content","initial-scale="+s+", maximum-scale="+s+", minimum-scale="+s+", user-scalable=no"),n.firstElementChild)n.firstElementChild.appendChild(o);else{var x=r.createElement("div");x.appendChild(o),r.write(x.innerHTML)}e.addEventListener("resize",function(){clearTimeout(a),a=setTimeout(i,300)},!1),e.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(a),a=setTimeout(i,300))},!1),"complete"===r.readyState?r.body.style.fontSize=12*m+"px":r.addEventListener("DOMContentLoaded",function(e){r.body.style.fontSize=12*m+"px"},!1),i(),d.dpr=e.dpr=m,d.refreshRem=i,d.rem2px=function(e){var t=parseFloat(e)*this.rem;return"string"==typeof e&&e.match(/rem$/)&&(t+="px"),t},d.px2rem=function(e){var t=parseFloat(e)/this.rem;return"string"==typeof e&&e.match(/px$/)&&(t+="rem"),t}}(window,window.lib||(window.lib={}));

    function isWeiXin() {
      var ua = window.navigator.userAgent.toLowerCase();
      if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        return true;
      } else {
        return false;
      }
    }

    function detectVersion() {
      let isAndroid, isIOS, isIOS9, version,
        u = navigator.userAgent,
        ua = u.toLowerCase();

      if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) { //android终端或者uc浏览器
        //Android系统
        isAndroid = true
      }

      if (ua.indexOf("like mac os x") > 0) {
        //ios
        var regStr_saf = /os [\d._]*/gi;
        var verinfo = ua.match(regStr_saf);
        version = (verinfo + "").replace(/[^0-9|_.]/ig, "").replace(/_/ig, ".");
      }
      var version_str = version + "";
      if (version_str != "undefined" && version_str.length > 0) {
        version = parseInt(version)
        if (version >= 8) {
          // ios9以上
          isIOS9 = true
        } else {
          isIOS = true
        }
      }
      return {
        isAndroid,
        isIOS,
        isIOS9
      }
    }

    // 判断手机上是否安装了app，如果安装直接打开url，如果没安装，执行callback
    function openApp(url, callback) {
      let {
        isAndroid,
        isIOS,
        isIOS9
      } = detectVersion()
      if (isAndroid || isIOS) {
        var timeout, t = 4000,
          hasApp = true;
        var openScript = setTimeout(function () {
          if (!hasApp) {
            callback && callback()
          }
          document.body.removeChild(ifr);
        }, 5000)
        var t1 = Date.now();
        var ifr = document.createElement("iframe");
        ifr.setAttribute('src', url);
        ifr.setAttribute('style', 'display:none');
        document.body.appendChild(ifr);

        timeout = setTimeout(function () {
          var t2 = Date.now();
          if (t2 - t1 < t + 100) {
            hasApp = false;
          }
        }, t);
      }
      
      if (isIOS9) {
        location.href = url;
        setTimeout(function () {
          callback && callback()
        }, 250);
        setTimeout(function () {
          location.reload();
        }, 1000);
      }
    }
    
    // 根据系统切换提示浏览器图标
    var ua = detectVersion();
    if(ua.isIOS9 || ua.isIOS){
      document.getElementById("sStepIcon").className = 's-step-icon';
    }

    //跳h5
    function goConfirmAddr() {
      window.location.href = 'https://youhui.95516.com/hybrid_v4/html/help/download.html'
    }
    window.onload = function () {
      gotoApp()
    }

    function gotoApp() {
      if (isWeiXin()) {
        document.getElementById("sMask").style.display = 'block';
      } else {
        openApp("chsp://fjlike.95516.com/app/usertask/awardCenter", goConfirmAddr)
      }
    }
  </script>
</html>